#ifndef __TINYSRV_ICALLBACK_H__
#define __TINYSRV_ICALLBACK_H__

#include "non_copyable.h"


namespace tinySrv
{

  struct ICallback
  {
    virtual ~ICallback()
    {
    }
    virtual void Do() = 0;
  };
  
  template <typename T>
  class ICallbackImpl
    : private NonCopyable
    , public ICallback
  {
  public:
    typedef void (T::*PMethod)();
    ICallbackImpl(T &object, PMethod method)
      : Object(object)
      , Method(method)
    {
    }
    virtual void Do()
    {
      (Object.*Method)();
    }
    
  private:
    T &Object;
    PMethod Method;
  };

}

#endif  // !__TINYSRV_ICALLBACK_H__
